//
//  ZJCommItem.m
//  ZiJinLian
//
//  Created by lc on 2017/3/20.
//  Copyright © 2017年 lzy. All rights reserved.
//

#import "ZJCommItem.h"

@implementation ZJCommItem



-(instancetype)initWithFrame:(CGRect)frame{

    if (self==[super initWithFrame:frame]) {
        self.backgroundColor=[UIColor whiteColor];
       
        
    }

    return self;
}

-(instancetype)withTypeItemType:(ZJItemType)type title:(NSString*)title{
    
    switch (type) {
        case ZJCOMM:
            
            return [self createZJCommItemTitle:title];
        case ZJARROW:
            
            return [self createZJArrowItemTitle:title];
        case ZJONLYTXT:
            
            return [self createOnlyText:title];
        case ZJCHECK:
            
            return  [self createCheckItem:title];
            
        case ZJARROW_TEXT:

            return  [self createArrowTextItem:title];
    }
  
    return  nil;
}

-(instancetype)createZJCommItemTitle:(NSString*) title{
     self.userInteractionEnabled=YES;
    _titleLab=[[UILabel alloc]init];
    _titleLab.font=FontAndStyle14;
    _titleLab.textColor=TextColor3;
    _titleLab.text=title;
    
    [self addSubview:_titleLab];
    [_titleLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.mas_left).offset(10);
        make.centerY.equalTo(self.mas_centerY);
        make.width.mas_equalTo(80);
    }];
    _cutLine=[[UIView alloc]init];
    _cutLine.backgroundColor=RGB(230, 230, 230);
    [self addSubview: _cutLine];
    [_cutLine mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(self.mas_bottom);
        make.left.equalTo(self.mas_left);
        make.height.mas_equalTo(0.5);
        make.width.equalTo(self.mas_width);
    }];
    _textField=[[UITextField alloc]init];
    _textField.font=[UIFont systemFontOfSize:14];
    _textField.textColor=TextColor3;
    [self addSubview:_textField];
    [_textField mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.mas_right).offset(-10);
        make.centerY.equalTo(self.mas_centerY);
        make.top.equalTo(self.mas_top).offset(10);
        make.bottom.equalTo(self.mas_bottom).offset(-10);
        make.left.equalTo(_titleLab.mas_right);
        
    }];
    return  self;
}
-(instancetype)createZJArrowItemTitle:(NSString*) title{
    _titleLab=[[UILabel alloc]init];
    _titleLab.font=FontAndStyle14;
    _titleLab.textColor=TextColor3;
    _titleLab.text=title;
    [self addSubview:_titleLab];
    [_titleLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.mas_left).offset(10);
        make.centerY.equalTo(self.mas_centerY);
        make.width.mas_equalTo(100);
    }];
    _cutLine=[[UIView alloc]init];
    _cutLine.backgroundColor=RGB(230, 230, 230);
    [self addSubview: _cutLine];
    [_cutLine mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(self.mas_bottom);
        make.left.equalTo(self.mas_left);
        make.height.mas_equalTo(0.5);
        make.width.equalTo(self.mas_width);
    }];
    _arrows=[[ UIImageView alloc]initWithImage:[UIImage imageNamed:@"icon_arrow_right"]];
    [self addSubview:_arrows];
    [_arrows mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.mas_centerY);
        make.right.equalTo(self.mas_right).offset(-10);
   
    }];
    return self;
}

-(instancetype)createArrowTextItem:(NSString*)title{
 
    _titleLab=[[UILabel alloc]init];
    _titleLab.font=FontAndStyle14;
    _titleLab.textColor=TextColor3;
    _titleLab.text=title;
    [self addSubview:_titleLab];
    [_titleLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.mas_left).offset(10);
        make.centerY.equalTo(self.mas_centerY);
        make.width.mas_equalTo(100);
    }];
    _cutLine=[[UIView alloc]init];
    _cutLine.backgroundColor=RGB(230, 230, 230);
    [self addSubview: _cutLine];
    [_cutLine mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(self.mas_bottom);
        make.left.equalTo(self.mas_left);
        make.height.mas_equalTo(0.5);
        make.width.equalTo(self.mas_width);
    }];
    _arrows=[[ UIImageView alloc]initWithImage:[UIImage imageNamed:@"icon_arrow_right"]];
    [self addSubview:_arrows];
    [_arrows mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.mas_centerY);
        make.right.equalTo(self.mas_right).offset(-10);
        
    }];
    _secondLab=[[UILabel alloc]init];
    _secondLab.font=FontAndStyle14;
    _secondLab.textColor=TextColor3;
    [self addSubview:_secondLab];
    [_secondLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(_titleLab.mas_right);
        make.centerY.equalTo(self.mas_centerY);
        make.right.equalTo(self.mas_right).offset(-30);
        
    }];
    return self;
   
}

-(instancetype)createOnlyText:(NSString*)text{
    _textField=[[UITextField alloc]init];
    _textField.placeholder=text;
    _textField.font=FontAndStyle14;
    _textField.textColor=TextColor3;
    [self addSubview:_textField];
    [_textField mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.mas_right).offset(-10);
        make.centerY.equalTo(self.mas_centerY);
        make.top.equalTo(self.mas_top).offset(10);
        make.bottom.equalTo(self.mas_bottom).offset(-10);
        make.left.equalTo(self.mas_left).offset(10);
    }];
    _cutLine=[[UIView alloc]init];
    _cutLine.backgroundColor=RGB(230, 230, 230);
    [self addSubview: _cutLine];
    [_cutLine mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(self.mas_bottom);
        make.left.equalTo(self.mas_left);
        make.height.mas_equalTo(0.5);
        make.width.equalTo(self.mas_width);
    }];
    return  self;
}

-(instancetype)createCheckItem:(NSString*)text{
    _titleLab=[[UILabel alloc]init];
    _titleLab.font=FontAndStyle14;
    _titleLab.textColor=TextColor3;
    _titleLab.text=text;
    [self addSubview:_titleLab];
    [_titleLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.mas_left).offset(10);
        make.centerY.equalTo(self.mas_centerY);
        make.width.mas_equalTo(100);
    }];
    _checkBox=[UIButton buttonWithType:UIButtonTypeCustom];
    [_checkBox setImage:[UIImage imageNamed:@"icon_rb_nor"] forState:UIControlStateNormal];
    [_checkBox setImage:[UIImage imageNamed:@"icon_rb_pre"] forState:UIControlStateSelected];
    _checkBox.selected=NO;
    [self addSubview:_checkBox];
    [_checkBox mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.mas_right).offset(-10);
        make.centerY.equalTo(self.mas_centerY);
        
    }];
    return self;
}

@end
